package com.ruoyi.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.domain.FundingApplication;
import com.ruoyi.service.IFundingApplicationService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 资金申请Controller
 * 
 * @author ruoyi
 * @date 2025-01-11
 */
@RestController
@RequestMapping("/fundingApplication")
public class FundingApplicationController extends BaseController
{
    @Autowired
    private IFundingApplicationService fundingApplicationService;

    /**
     * 查询资金申请列表
     */
    @RequiresPermissions("fljg:fundingApplication:list")
    @GetMapping("/list")
    public TableDataInfo list(FundingApplication fundingApplication)
    {
        startPage();
        List<FundingApplication> list = fundingApplicationService.selectFundingApplicationList(fundingApplication);
        return getDataTable(list);
    }

    /**
     * 导出资金申请列表
     */
    @RequiresPermissions("fljg:fundingApplication:export")
    @Log(title = "资金申请", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FundingApplication fundingApplication)
    {
        List<FundingApplication> list = fundingApplicationService.selectFundingApplicationList(fundingApplication);
        ExcelUtil<FundingApplication> util = new ExcelUtil<FundingApplication>(FundingApplication.class);
        util.exportExcel(response, list, "资金申请数据");
    }

    /**
     * 获取资金申请详细信息
     */
    @RequiresPermissions("fljg:fundingApplication:query")
    @GetMapping(value = "/{fuid}")
    public AjaxResult getInfo(@PathVariable("fuid") Long fuid)
    {
        return success(fundingApplicationService.selectFundingApplicationByFuid(fuid));
    }

    /**
     * 新增资金申请
     */
    @RequiresPermissions("fljg:fundingApplication:add")
    @Log(title = "资金申请", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FundingApplication fundingApplication)
    {
        return toAjax(fundingApplicationService.insertFundingApplication(fundingApplication));
    }

    /**
     * 修改资金申请
     */
    @RequiresPermissions("fljg:fundingApplication:edit")
    @Log(title = "资金申请", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FundingApplication fundingApplication)
    {
        return toAjax(fundingApplicationService.updateFundingApplication(fundingApplication));
    }

    /**
     * 删除资金申请
     */
    @RequiresPermissions("fljg:fundingApplication:remove")
    @Log(title = "资金申请", businessType = BusinessType.DELETE)
	@DeleteMapping("/{fuids}")
    public AjaxResult remove(@PathVariable Long[] fuids)
    {
        return toAjax(fundingApplicationService.deleteFundingApplicationByFuids(fuids));
    }
}
